﻿<Window x:Class="QSWPFApplicationCSharp.BasicWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:BusinessLayer="clr-namespace:QSBusinessLayerCSharp;assembly=QSBusinessLayerCSharp"
	xmlns:ValidationFrameworkWPF="clr-namespace:ValidationFramework.WPF;assembly=ValidationFramework.WPF"
	xmlns:System="clr-namespace:System;assembly=mscorlib"
    Title="BasicWindow" MinHeight="316" MinWidth="596" ResizeMode="NoResize">
	<Window.Resources>
		<CollectionViewSource x:Key="AvailableGenders">
			<CollectionViewSource.Source>
				<ObjectDataProvider 
					MethodName="GetNames" 
					ObjectType="{x:Type System:Enum}">
					<ObjectDataProvider.MethodParameters>
						<x:Type TypeName="BusinessLayer:Gender"/>
					</ObjectDataProvider.MethodParameters>
				</ObjectDataProvider>
			</CollectionViewSource.Source>
		</CollectionViewSource>
		<ValidationFrameworkWPF:EnumValueConverter x:Key="enumValueConverter"/>
		<Style TargetType="{x:Type TextBox}" >
			<Setter Property="Validation.ErrorTemplate">
				<Setter.Value>
					<ControlTemplate>
						<Border BorderBrush="Blue" BorderThickness="2">
							<AdornedElementPlaceholder />
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

		<Style TargetType="{x:Type StackPanel}" >
			<Setter Property="Validation.ErrorTemplate" >
				<Setter.Value>
					<ControlTemplate>
						<Border BorderBrush="Blue" BorderThickness="2">
							<AdornedElementPlaceholder />
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>

		</Style>

		<Style TargetType="{x:Type ComboBox}" >
			<Setter Property="Validation.ErrorTemplate" >
				<Setter.Value>
					<ControlTemplate>
						<Border BorderBrush="Blue" BorderThickness="2">
							<AdornedElementPlaceholder />
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>

		</Style>

	</Window.Resources>
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="*" />
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="*" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>
		<Grid  Grid.Column="0" Grid.Row="0" Name="grid1" >
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto"   />
				<ColumnDefinition Width="150" />
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
			</Grid.RowDefinitions>
			<TextBlock Grid.Column="0" Grid.Row="0">First Name</TextBlock>
			<TextBox Grid.Column="1" Grid.Row="0" Name="a" HorizontalScrollBarVisibility="Auto"  >
				<ValidationFrameworkWPF:ValidationBinding  Path="FirstName"  UpdateSourceTrigger="PropertyChanged" />
			</TextBox>
			<TextBlock Grid.Column="0" Grid.Row="1">Last Name</TextBlock>
			<TextBox Grid.Column="1" Grid.Row="1">
				<ValidationFrameworkWPF:ValidationBinding Path="LastName"  UpdateSourceTrigger="PropertyChanged" />
			</TextBox>
			<TextBlock Grid.Column="0" Grid.Row="2">Age</TextBlock>
			<TextBox Grid.Column="1" Grid.Row="2">
				<ValidationFrameworkWPF:ValidationBinding Path="Age"  UpdateSourceTrigger="PropertyChanged"  StringFormat="{}{0:C2}" />
			</TextBox>
			<TextBlock Grid.Column="0" Grid.Row="3">Email</TextBlock>
			<TextBox Grid.Column="1" Grid.Row="3" >
				<ValidationFrameworkWPF:ValidationBinding Path="EmailAddress"  UpdateSourceTrigger="PropertyChanged"  />
			</TextBox>
			<TextBlock Grid.Column="0" Grid.Row="4">Phone</TextBlock>
			<TextBox Grid.Column="1" Grid.Row="4" >
				<ValidationFrameworkWPF:ValidationBinding Path="PhoneNumber"  UpdateSourceTrigger="PropertyChanged" />
			</TextBox>
			<TextBlock Grid.Column="0" Grid.Row="5">CardType</TextBlock>
			<StackPanel  Grid.Column="1" Grid.Row="5" Orientation="Vertical">
				<RadioButton x:Name="amexRadioButton" Content="Amex" GroupName="{Binding Id}">
					<RadioButton.IsChecked>
						<ValidationFrameworkWPF:ValidationBinding Path="CardType" Converter="{StaticResource enumValueConverter}" ConverterParameter="Amex"  UpdateSourceTrigger="PropertyChanged"  />
					</RadioButton.IsChecked>
				</RadioButton>
				<RadioButton x:Name="masterCardRadioButton" Content="MasterCard" GroupName="{Binding Id}">
					<RadioButton.IsChecked>
						<ValidationFrameworkWPF:ValidationBinding Path="CardType" Converter="{StaticResource enumValueConverter}" ConverterParameter="MasterCard" UpdateSourceTrigger="PropertyChanged"  />
					</RadioButton.IsChecked>
				</RadioButton>
				<RadioButton x:Name="visaRadioButton" Content="Visa" GroupName="{Binding Id}">
					<RadioButton.IsChecked>
						<ValidationFrameworkWPF:ValidationBinding Path="CardType" Converter="{StaticResource enumValueConverter}" ConverterParameter="Visa" UpdateSourceTrigger="PropertyChanged"   />
					</RadioButton.IsChecked>
				</RadioButton>
			</StackPanel>
			<TextBlock Grid.Column="0" Grid.Row="6">Credit Card Number</TextBlock>
			<TextBox Grid.Column="1" Grid.Row="6">
				<ValidationFrameworkWPF:ValidationBinding Path="CreditCardNumber"  UpdateSourceTrigger="PropertyChanged" />
			</TextBox>
			<TextBlock Grid.Column="0" Grid.Row="7">Order Total</TextBlock>
			<TextBox Grid.Column="1" Grid.Row="7">
				<ValidationFrameworkWPF:ValidationBinding Path="OrderTotal"  UpdateSourceTrigger="PropertyChanged" />
			</TextBox>
			<TextBlock Grid.Column="0" Grid.Row="8">Address Line 1</TextBlock>
			<TextBox Grid.Column="1" Grid.Row="8">
				<ValidationFrameworkWPF:ValidationBinding Path="Address.AddressLine1"  UpdateSourceTrigger="PropertyChanged" />
			</TextBox>
			<TextBlock Grid.Column="0" Grid.Row="9">Address Line 2</TextBlock>
			<TextBox Grid.Column="1" Grid.Row="9">
				<ValidationFrameworkWPF:ValidationBinding Path="Address.AddressLine2"  UpdateSourceTrigger="PropertyChanged" />
			</TextBox>
			<TextBlock Grid.Column="0" Grid.Row="10">Gender</TextBlock>
			<ComboBox  Grid.Column="1" Grid.Row="10">
				<ComboBox.ItemsSource>
					<Binding Source="{StaticResource AvailableGenders}"/>
				</ComboBox.ItemsSource>
				<ComboBox.SelectedValue>
					<ValidationFrameworkWPF:ValidationBinding Path="Gender"  UpdateSourceTrigger="PropertyChanged" />
				</ComboBox.SelectedValue>
			</ComboBox>
		</Grid>
		<TreeView Name="errorTreeView" Grid.Row="0" Grid.Column="1"/>
		<Button Grid.Column="1" Grid.Row="1" Height="Auto" HorizontalAlignment="Right"  Name="closeButton" VerticalAlignment="Top" Width="Auto" Click="closeButton_Click" Content="Validate and Close"/>
	</Grid>
</Window>
